Imports System
Imports System.Xml

Public Class XmlReader

	Public Sub New()

	End Sub

	Public Sub ReadIni()
		Dim doc As New XmlDocument
		Dim inifile As String = Application.StartupPath()
		If Right(inifile, 3) = "bin" Then
			inifile = inifile.Substring(0, inifile.Length - 4)
		End If
		inifile &= "\client.xml"

		Dim reader As New XmlTextReader(inifile)
		Dim x As Integer
		Dim node As XmlNode
		Dim col As XmlNode
		Dim attr As XmlAttribute

		Try
			doc.Load(reader)
			Dim root As XmlNode = doc.DocumentElement

			'<http>
			'	<useProxy>false</useProxy>
			'	<responseTimeout>60000</responseTimeout>
			'	<proxyHost></proxyHost>
			'	<proxyPort></proxyPort>
			'	<connectionTimeout>6000</connectionTimeout>
			'</http>
			'<cpc>
			'	<httpapi>
			'		<server hostname="www.marketing.services.nymex.com" port="443" protocol="https" service="cpc/cpcapihtml"></server>
			'	</httpapi>
			'</cpc>

			For Each node In root.ChildNodes

				Select Case node.Name
					Case "http"
						For Each col In node.ChildNodes
							Select Case col.Name
								Case "useProxy"
									Globals.UseProxy = col.InnerText

								Case "responseTimeout"
								Case "proxyHost"
								Case "proxyPort"
								Case "connectionTimeout"

							End Select
						Next

					Case "cpc"
						col = node.ChildNodes(0)

						If col.Name = "httpapi" Then
							col = col.ChildNodes(0)
							If col.Name = "server" Then
								Globals.HostName = col.Attributes("hostname").InnerText
								Globals.Port = col.Attributes("port").InnerText
								Globals.Protocol = col.Attributes("protocol").InnerText
								Globals.Service = col.Attributes("service").InnerText
								'For Each attr In col.Attributes
								'	Select Case attr.Name
								'		Case "hostname"
								'			Globals.HostName = attr.Value

								'		Case "port"
								'			Globals.Port = attr.Value

								'		Case "protocol"
								'			Globals.Protocol = attr.Value

								'		Case "service"
								'			Globals.Service = attr.Value

								'	End Select
								'Next
							End If

						End If

					Case "DBConnection"
						Globals.DBConnection = node.InnerText

				End Select

			Next
		Catch ex As Exception
			'			Log.LogData("err - XML Error: " & ex.Message)
		Finally
			reader.Close()
		End Try
	End Sub

End Class
